Skip to content

Don't ICE when rustc changes the return type of catch_unwind - #4996

Merged
feliperodri merged 3 commits into
model-checking:mainfrom
paulocsanz:rfc0475-catch-unwind-sig-drift
Nov 9, 2026
Merged

feliperodri merged 3 commits into
model-checking:mainfrom
paulocsanz:rfc0475-catch-unwind-sig-drift

Conversation

@paulocsanz

@paulocsanz paulocsanz commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Kani 0.68.0 ICEs on anything that reaches catch_unwind (std::panic::catch_unwind, thread::spawn(..).join(), BufReader):

thread 'rustc' panicked at kani-compiler/src/intrinsics.rs:243:17:
assertion failed: matches!(output.kind(), TyKind :: RigidTy(RigidTy::Int(IntTy::I32)))

rustc changed the intrinsic's return type from i32 to bool in rust-lang/rust#156867 and the assert_sig_matches! in Intrinsic::from_instance still said i32. #4819 changed it to bool (#4813).

The intrinsic is Unimplemented (#267) and the arm never looks at the return type, so this PR stops asserting it: => _, like bitreverse, black_box, discriminant_value and the *_fast arms. Next time rustc changes it, the user gets catch_unwind is not currently supported by Kani instead of an ICE. Arguments and arity are still asserted.

Covered by tests/expected/intrinsics/catch-unwind from #4819.

@paulocsanz
paulocsanz requested review from a team as code owners October 11, 2026 15:12
@github-actions github-actions Bot added Z-EndToEndBenchCI Tag a PR to run benchmark CI Z-CompilerBenchCI Tag a PR to run benchmark CI labels Oct 11, 2026
@feliperodri
feliperodri requested a balanced review from Copilot October 11, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change safely preserves unsupported-intrinsic reporting while avoiding version-specific signature assertions.

0 open findings

What changed in this PR

Prevents compiler ICEs when rustc changes the return type of the unsupported catch_unwind intrinsic.

Changes:

  • Allows any catch_unwind output type while retaining argument validation.
  • Documents the rustc signature drift and existing unsupported behavior.
File Description
kani-compiler/​src/​intrinsics.rs Relaxes catch_unwind return-type validation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@paulocsanz

Copy link
Copy Markdown
Contributor Author

Hi, I'm sorry I was not aware a LLM opened this, I asked it to make a fork of my own and fix it there until I had time to properly report.

I will review this, fix the description being in portuguese and invest proper human time into it. Sorry for the noise, although it does seem to be in the right direction.

@paulocsanz
paulocsanz force-pushed the rfc0475-catch-unwind-sig-drift branch from 951ac6a to 0225a1c Compare October 13, 2026 23:43
@paulocsanz paulocsanz changed the title intrinsics: stop ICEing on catch_unwind signature drift across rustc versions Accept any return type for the unimplemented catch_unwind intrinsic Oct 13, 2026
Kani 0.68.0 ICEs on anything that reaches `catch_unwind`: rustc changed
the intrinsic's return type from `i32` to `bool` (rust-lang/rust#156867)
and `assert_sig_matches!` still said `i32`. model-checking#4819 changed it to `bool`
(model-checking#4813).

The intrinsic is `Unimplemented` (model-checking#267) and the arm never looks at the
return type, so stop asserting it (`=> _`, like `bitreverse`, `black_box`,
`discriminant_value` and the `*_fast` arms). Next time rustc changes it
the user gets the unsupported-construct failure instead of an ICE.
Arguments and arity are still asserted.

Covered by tests/expected/intrinsics/catch-unwind from model-checking#4819.
@paulocsanz paulocsanz changed the title Accept any return type for the unimplemented catch_unwind intrinsic Don't ICE when rustc changes the return type of catch_unwind Oct 13, 2026
@paulocsanz
paulocsanz force-pushed the rfc0475-catch-unwind-sig-drift branch from 0225a1c to 74f93db Compare October 13, 2026 23:46
@feliperodri

Copy link
Copy Markdown
Member

Hi, I'm sorry I was not aware a LLM opened this, I asked it to make a fork of my own and fix it there until I had time to properly report.

I will review this, fix the description being in portuguese and invest proper human time into it. Sorry for the noise, although it does seem to be in the right direction.

Sem problemas, @paulocsanz! Nós agradecemos da mesma forma a contribuição e você agir prontamente logo depois da LLM. Obrigado 😄

@feliperodri

Copy link
Copy Markdown
Member

@paulocsanz should we convert this as draft?

@paulocsanz

Copy link
Copy Markdown
Contributor Author

Why? Is it not ready to be merged? What change do you need?

@feliperodri feliperodri added [C] Bug This is a bug. Something isn't working. Z-Autoharness Issue related to autoharness subcommand labels Nov 6, 2026
@feliperodri feliperodri added this to the Autoharness milestone Nov 6, 2026
@feliperodri feliperodri removed the Z-Autoharness Issue related to autoharness subcommand label Nov 6, 2026
@feliperodri feliperodri removed this from the Autoharness milestone Nov 6, 2026

@feliperodri feliperodri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow answer, @paulocsanz: nothing else is needed. My question came from the LLM note, but the change is right. #4819 fixed the bool return type on main, and this keeps the next rustc change from crashing the compiler, since the unimplemented intrinsic never uses its return type. I added [F] Crash. Obrigado!

@feliperodri feliperodri added the [F] Crash Kani crashed label Nov 9, 2026
@feliperodri
feliperodri added this pull request to the merge queue Nov 9, 2026
Merged via the queue into model-checking:main with commit f51993f Nov 9, 2026
26 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[C] Bug This is a bug. Something isn't working. [F] Crash Kani crashed Z-CompilerBenchCI Tag a PR to run benchmark CI Z-EndToEndBenchCI Tag a PR to run benchmark CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants